<?php

    sfContext::getInstance()->getResponse()->addStylesheet('/jwSocketPlugin/css/main.css' );
    sfContext::getInstance()->getResponse()->addJavascript( '/jwSocketPlugin/js/InPlace.js' );
    
    $i18n = new sfI18N( sfContext::getInstance()->getConfiguration(), null, array('culture' => 'hu' ) );
    if ( sfContext::getInstance()->getUser()->hasCredential( 'edit' ) )
    {
        $tmp = new inPlaceRichEditor();
        $tmp->initialize( 'abc', $socket->getContent(), array( 'i18n' => $i18n, 'css' => '/css/main.css',
                                        'culture' => 'hu',
                                        'tinymce_options' => ' width: "100%",
                                        height: "350",
                                        external_image_list_url : "/jwSocketPlugin/js/image_list.js",
                                        template_replace_values : {
                                            contact         :   "'.__("contact").'",
                                            telephone       :   "'.__("telephone").'",
                                            address         :   "'.__("address").'",
                                            email           :   "'.__("email").'",
                                            vcard           :   "'.__("getAsVcard").'",
                                            replace_phone   :   "'.$i18n->__("replace_phone").'",
                                            replace_address :   "'.$i18n->__("replace_address").'",
                                            replace_email   :   "'.$i18n->__("replace_email").'",
                                        },
                                        template_templates : [
                                            {
                                              title : "Editor Details",
                                              src : "/editor_details.htm",
                                              description : "Adds Editors Name and Staff ID"
                                            },
                                            {
                                                title       : "'.$i18n->__('contact_template').'",
                                                src         : "/contact_template.htm",
                                                description : "'.$i18n->__('contact_template_description').'"    
                                            }
              ]' ), 'function( _content ){ $.post( "'.url_for( 'jwSocket/save' ).'", { content : this } ) }' );
        echo $tmp->toHTML();
        sfContext::getInstance()->getUser()->setAttribute( 'id', $socket->getId(), 'socket' );
    }
    else
    {
        echo $socket->getContent();
    }
    
?>